Thread safety can be an important concern in database processing operations and also in any kind of server application in which high availability and data integrity are desirable. In general, a thread is the smallest sequence of programmed instructions that can be managed independently by an operating system scheduler. For example, avoidance of race conditions and deadlocks can be desirable, as can ensuring a consistent state after an error rollback, avoidance of synchronization bottlenecks, and the like. As used herein, the term database can refer generally to any of a relational database, a data cube, a column store database, a row store database, data stored on one or more tables or other data structures, or the like.
A race condition can occur when two or more programs (or independent parts of a single program) or programming objects attempt to acquire or otherwise take ownership of the same resource at the same time, resulting in an incorrect answer or conflict. The resource can include information, such as for example a next available appointment time, etc., or it can include exclusive access to an entity, such as for example a database table, one or more records, or the like. As used herein, a programming object represents a programming concept using data fields or attributes that define the object and associated procedures (also referred to as methods). Programming objects can interact with one another to design applications and computer programs.
A deadlock can occur in multiprocessing systems, parallel computing and distributed systems in which software and hardware locks are used to handle shared resources and implement process synchronization. For example, a deadlock can occur when a process enters a waiting state because a resource requested by the process is being held by another waiting process, which in turn is waiting for another resource. If a process is unable to change its state indefinitely because the resource it requested is being used by another waiting process, then the system is said to be in a deadlock.
A database commit occurs when a permanent change is made to a database. For example, when a new row is written to the database, the write operation does not occur until the database commits the change. Rollback is the process of undoing a change to a database. For example, when a new row is written to a table, the write operation can undergo a rollback up to the point at which the write is committed. After the commit, a rollback of the write operation is generally no longer possible.
Synchronization bottlenecks can occur when multiple threads attempt to concurrently update the same programming object (e.g. a C++ object, a C++ class, or other objects or classes of object-based programming languages). It is often possible to eliminate synchronization bottlenecks by replicating programming objects. Each thread can then update its own local replica of the programming object without synchronization and without interacting with other threads. When the original programming object needs to be accessed, the replicas may be combined to produce the correct values in the original programming object. One potential problem is that replicating programming objects may lead to performance degradation and excessive memory consumption.
Proper memory management can also be important. Intelligent memory management and allocation can include one or more of avoidance of memory leaks (including, but not limited to error situations), avoidance of dangling pointers (e.g. memory may not be used after it has been deallocated), memory consumption analysis support, fast memory allocation (e.g. allocation and release of memory in large chunks where possible reduces the cost of allocation), and the like.
Further, as the complexity of a database increases, the number of requests from one or more applications to access programming objects and the potential for violations of one or more thread safety goals also increases.